package no.sachmuld.methodcombination.examples.adapter.javastyle;

import no.sachmuld.methodcombination.api.BehaviourChain;
import no.sachmuld.methodcombination.api.MethodInvocation;
import no.sachmuld.methodcombination.api.adapter.Default;

/**
 *
 */
public abstract class Foo {

    private BehaviourChain<FooBehaviour> chain = new BehaviourChain<>();

    final public void bar() {
        new Default<FooBehaviour, Void>(chain) {
            @Override
            protected Void executeBehaviour(FooBehaviour behaviour, MethodInvocation<Void> methodInvocation) {
                behaviour.bar(methodInvocation);
                return null;
            }
        }.execute();
    }

    public void baz() {
    }

    final protected Foo with(FooBehaviour... fooBehaviours) {
        chain.addAll(fooBehaviours);
        return this;
    }


}
